//https://cn.vitejs.dev/guide/features.html#glob-import
// 防止打包后图片路径解析成字符串
export const getSrc: any = (name: string) => {
  const path = `/src/assets/${name}`
  const modules = import.meta.globEager('/src/assets/*')
  return modules[path].default
}

export function isUnDef<T = unknown>(val?: T): val is T {
  return !isDef(val);
}

export function isDef<T = unknown>(val?: T): val is T {
  return typeof val !== 'undefined';
}

export function isNull(val: unknown): val is null {
  return val === null;
}

export function isNullOrUnDef(val: unknown): val is null | undefined {
  return isUnDef(val) || isNull(val);
}

export function isFunction(val: unknown): val is Function {
  return typeof val === 'function';
}
